package com.simple.simple_view.controller.comment;

import com.simple.simple_view.domain.ResponseResult;
import com.simple.simple_view.domain.dto.CommentDto;
import com.simple.simple_view.domain.enums.AppHttpCodeEnum;
import com.simple.simple_view.exception.SystemException;
import com.simple.simple_view.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/*
 *@description: 评论接口
 *@author: hisen
 *@Time: 2023/11/2  18:02
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    CommentService commentService;
    @PostMapping("/publish")
    public ResponseResult publish(@RequestBody CommentDto commentDto){
        if (commentDto.getVideoId()==null) {
            throw new SystemException(AppHttpCodeEnum.VIDEO_ID_NOT_NULL);
        }
        if (commentDto.getContent()==null) {
            throw new SystemException(AppHttpCodeEnum.COMMENT_CONTENT_ERROR);
        }

        return commentService.publishComment(commentDto);
    }
    @GetMapping("/page")
    public ResponseResult getCommentPage(@RequestParam int currentPage,@RequestParam int pageSize){
        return commentService.getCommentPage(currentPage,pageSize);
    }

}
